//98

Definition for a binary tree node.
public class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode() {}
    TreeNode(int val) { this.val = val; }
    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}

class Solution {
  public boolean isValidBST(TreeNode root) {
      ListInteger list = new ArrayList();
      mid(root, list);
      for (int i = 1; i  list.size(); i++) {
          if (list.get(i) = list.get(i-1)) {
              return false;
          }
      }
      return true;
  }

  public void mid(TreeNode root, ListInteger list) {
      if (root == null ) {
          return;
      }
      mid(root.left, list);
      list.add(root.val);
      mid(root.right, list);
  }
}
小红拿到了一个正整数 x  。她可以将其中一些数位染成红色。然后她想让所有染红的数位数字之和等于没染色的数位数字之和。
她不知道能不能达成目标。你能告诉她吗？
输入描述：
一个正整数 x，1≤x≤10^18
 

输出描述：
如果小红能按要求完成染色，输出"Yes"。否则输出"No"


#include <iostream>
#include <cstring>
using namespace std;

int main() 
{
    char arr[20] = {0};
    int arr1[20] = {0};
    int sum = 0;
    cin >> arr;
    int len = strlen(arr);
    for (int i = 0; i < len; i++)
    {
        arr1[i] = arr[i] - '0';
    }
    for (int i = 0; i < len; i++)
    {
        sum += arr1[i];
    }
    int p[sum/2 + 1];
    for (int i = 0; i < sum/2 + 1; i++)
    {
        p[i] = 0;
    }
    if (sum % 2 == 0)
    {
        for (int i = 0; i < len; i++)
        {
            for (int j = sum/2; j >= arr1[i]; j--)
            {
                p[j] = (p[j-arr1[i]] + arr1[i]) > p[j-1] ? (p[j-arr1[i]] + arr1[i]) : p[j-1];
                if (p[j] == sum/2)
                {
                    cout << "Yes";
                    return 0;
                }
            }

        }

    }
    cout << "No";
    

    return 0;
}
// 64 位输出请用 printf("%lld")